package com.education.common;

import com.education.pojo.Admin;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 林心晨
 * @Title:
 * @Package
 * @Description:
 * @date create in 5.8  14:45
 */
public class RequestHolder {
    private static final ThreadLocal<Admin> userHolder = new ThreadLocal<Admin>();

    private static final ThreadLocal<HttpServletRequest> requestHolder = new ThreadLocal<HttpServletRequest>();

    public static void add(Admin admin) {
        userHolder.set(admin);
    }

    public static void add(HttpServletRequest request) {
        requestHolder.set(request);
    }

    public static Admin getCurrentAdmin() {
        return userHolder.get();
    }

    public static HttpServletRequest getCurrentRequest() {
        return requestHolder.get();
    }

    public static void remove() {
        userHolder.remove();
        requestHolder.remove();
    }

}
